package cn.netjava.robo3d;

import com.jme.image.Texture;
import com.jme.scene.Node;
import com.jme.scene.Skybox;
import com.jme.util.TextureManager;

public class Sky extends Node {

	private Skybox skybox;

	public Sky() {
		this.setName("skynode");
		skybox = new Skybox("skybox", 50, 50, 50);

		Texture north = TextureManager.loadTexture(Sky.class.getClassLoader()
				.getResource("cn/netjava/robo3d/images/north.jpg"),
				Texture.MinificationFilter.BilinearNearestMipMap,
				Texture.MagnificationFilter.Bilinear);
		Texture south = TextureManager.loadTexture(Sky.class.getClassLoader()
				.getResource("cn/netjava/robo3d/images/south.jpg"),
				Texture.MinificationFilter.BilinearNearestMipMap,
				Texture.MagnificationFilter.Bilinear);
		Texture east = TextureManager.loadTexture(Sky.class.getClassLoader()
				.getResource("cn/netjava/robo3d/images/east.jpg"),
				Texture.MinificationFilter.BilinearNearestMipMap,
				Texture.MagnificationFilter.Bilinear);
		Texture west = TextureManager.loadTexture(Sky.class.getClassLoader()
				.getResource("cn/netjava/robo3d/images/west.jpg"),
				Texture.MinificationFilter.BilinearNearestMipMap,
				Texture.MagnificationFilter.Bilinear);
		Texture up = TextureManager.loadTexture(Sky.class.getClassLoader()
				.getResource("cn/netjava/robo3d/images/clouds.png"),
				Texture.MinificationFilter.BilinearNearestMipMap,
				Texture.MagnificationFilter.Bilinear);
		Texture down = TextureManager.loadTexture(Sky.class.getClassLoader()
				.getResource("cn/netjava/robo3d/images/bottom.jpg"),
				Texture.MinificationFilter.BilinearNearestMipMap,
				Texture.MagnificationFilter.Bilinear);

		skybox.setTexture(Skybox.Face.North, north);
		skybox.setTexture(Skybox.Face.West, west);
		skybox.setTexture(Skybox.Face.South, south);
		skybox.setTexture(Skybox.Face.East, east);
		skybox.setTexture(Skybox.Face.Up, up);
		skybox.setTexture(Skybox.Face.Down, down);
		skybox.preloadTextures();
		this.attachChild(skybox);
	}

	public Skybox getskybox() {
		return skybox;
	}
}
